package com.ict.web.dto;


import com.alibaba.excel.annotation.ExcelProperty;
import com.ict.common.annotation.Excel;
import com.ict.web.annotation.ExcelAnnotation;
import com.ict.web.domain.ExtractExpert;
import com.ict.web.domain.GovernmentDataResources;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * @author xc
 */
@Data
@EqualsAndHashCode
public class UploadBatchDto {
    /**
     * 信息资源名称
     */
    @ExcelAnnotation(message = "信息资源名称")
    @ExcelProperty(index = 0)
     private String informationResourceName;

    /**
     * 信息资源来源系统
     */
    @ExcelAnnotation(message = "信息资源来源系统")
    @ExcelProperty(index = 1)
    private String informationResourceSourceSystem;

    /**
     * 信息资源代码
     */
    @ExcelAnnotation(message = "信息资源代码")
    @ExcelProperty(index = 2)
    private String informationResourceCode;

    /**
     * 信息资源提供方
     */
    @ExcelAnnotation(message = "信息资源提供方")
    @ExcelProperty(index = 3)
    private String informationResourceProvider;

    /**
     * 提供方内部部门
     */
    @ExcelProperty(index = 4)
    private String providersInternalDepartment;
    /**
     * 资源提供方代码
     */
    @ExcelAnnotation(message = "资源提供方代码")
    @ExcelProperty(index = 5)
    private String resourceProviderCode;


    /**
     * 信息资源摘要
     */
    @ExcelAnnotation(message = "信息资源摘要")
    @ExcelProperty(index = 6)
    private String summaryOfInformationResources;

    /**
     * 信息资源格式分类
     */
    @ExcelAnnotation(message = "信息资源格式分类")
    @ExcelProperty(index = 7)
    private String classificationOfInformationResourceFormats;

    /**
     * 信息资源格式类型
     */
    @ExcelAnnotation(message = "信息资源格式类型")
    @ExcelProperty(index = 8)
    private String informationResourceFormatType;

    /**
     * 选填：其他类型资源格式描述
     */
    @ExcelAnnotation(message = "选填：其他类型资源格式描述")
    @ExcelProperty(index =9)
    private String other;

    /**
     * 信息项名称
     */
    @ExcelProperty(index = 10)
    @ExcelAnnotation(message = "信息项名称")
    private String informationItemName;



    /**
     * 数据类型
     */
    @ExcelProperty(index = 11)
    @ExcelAnnotation(message = "数据类型")
    private String typeOfData;

    /**
     * 选填：数据长度
     */
    @ExcelProperty(index = 12)
    @ExcelAnnotation(message = "选填：数据长度")
    private String dataLength;

    /**
     * 共享类型
     */
    @ExcelProperty(index = 13)
    @ExcelAnnotation(message = "共享类型")
    private String shareType;

    /**
     * 共享条件
     */
    @ExcelProperty(index = 14)
    @ExcelAnnotation(message = "共享条件")
    private String sharingConditions;

    /**
     * 共享方式分类
     */
    @ExcelProperty(index = 15)
    @ExcelAnnotation(message = "共享方式分类")
    private String sharingModeClassification;

    /**
     * 共享方式类型
     */
    @ExcelProperty(index = 16)
    @ExcelAnnotation(message = "共享方式类型")
    private String sharingModeType;

    /**
     * 是否向社会开放
     */
    @ExcelProperty(index = 17)
    @ExcelAnnotation(message = "是否向社会开放")
    private String isOpen;

    /**
     * 开放条件
     */
    @ExcelProperty(index = 18)
    @ExcelAnnotation(message = "开放条件")
    private String openConditions;

    /**
     * 更新周期
     */
    @ExcelProperty(index = 19)
    @ExcelAnnotation(message = "更新周期")
    private String updateCycle;

    /**
     * 发布日期
     */
    @ExcelProperty(index = 20)
    @ExcelAnnotation(message = "发布日期")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime releaseDate;


    /**
     * 选填：平台目录标识
     */
    @ExcelProperty(index = 21)
    @ExcelAnnotation(message = "选填：平台目录标识")
    private String platformDirectoryId;


    /**
     * UploadBatchDto 转化为 ResourceCatalog
     *
     * @param dto 目录接收dto
     * @return ResourceCatalog
     */
    public static GovernmentDataResources toGovernmentDataResources(UploadBatchDto dto) {
        GovernmentDataResources bean = new GovernmentDataResources();
        BeanUtils.copyProperties(dto, bean);
        bean.setCreateTime(LocalDateTime.now());
        bean.setDelFlag(ExtractExpert.DELETE_STATUS_NORMAL);
        return bean;
    }
}
